package addon.w3.mdx.com;

import java.io.IOException;
import java.util.Vector;

import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
CAMS						// [Camera]
	long 	nbytes;
	struct {
		long 	nbytesi;
		ASCII 	Name; 			(0x50)
		float	PosX, PosY, PosZ;
		float	FieldOfView;
		float	FarClip;
		float	NearClip;
		struct	{ 			// Target
			float	x, y, z;
			(KCTR)
		}
		(KCRL)
		(KTTR)
	} cameras[ncams];

 * @author madjk
 */
public class MDXCameras extends MDXParentCOM {
	int length = -1;
	Vector cams = null;
	
	public String getTag() {
		return "CAMS";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		int cntLength = 0;
		cams = new Vector();
		while(cntLength < length) {
			MDXCameraCOM mdcom = new MDXCameraCOM();
			mdcom.decode(ins);
			cams.add(mdcom);
			cntLength += mdcom.nbytesi;
			//System.out.println(" cntLength : "+cntLength);
			//debug( mdcom.toString() );
		}
		//debug( attachments.get( 0 ).toString() );
		//debug( attachments.get( (attachments.size()-1) ).toString() );
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tELEN : "+length);
		if(cams != null && cams.size() > 0) sb.append("\n\tATTACHMENTS : "+cams.size());
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}